#include "Class/Entity/Image.hpp"

#include <iostream>
namespace		Entity
{
  bool			Image::SetImage(Image const &img)
  {
	if (!this->Component::Image::SetImage(img))
	  return (false);
	if (!this->_Sprite && !(this->_Sprite = new (std::nothrow) sf::Sprite))
	  return (false);

	this->_Sprite->SetImage(*this->_GetImage());
	this->_Sprite->SetCenter(this->_GetImage()->GetWidth() / 2.f, this->_GetImage()->GetHeight() / 2.f);
	return (this->_Sprite->GetImage() != NULL);
  }
  bool			Image::SetImage(std::string const &path)
  {
	if (!this->Component::Image::SetImage(path))
	  return (false);
	if (!this->_Sprite && !(this->_Sprite = new (std::nothrow) sf::Sprite))
	  return (false);

	this->_Sprite->SetImage(*this->_GetImage());
	this->_Sprite->SetCenter(this->_GetImage()->GetWidth() / 2.f, this->_GetImage()->GetHeight() / 2.f);
	return (this->_Sprite->GetImage() != NULL);
  }
  bool			Image::SetImage(sf::Image const &img)
  {
	if (!this->Component::Image::SetImage(img))
	  return (false);
	if (!this->_Sprite && !(this->_Sprite = new (std::nothrow) sf::Sprite))
	  return (false);

	this->_Sprite->SetImage(*this->_GetImage());
	this->_Sprite->SetCenter(this->_GetImage()->GetWidth() / 2.f, this->_GetImage()->GetHeight() / 2.f);
	return (this->_Sprite->GetImage() != NULL);
  }

  void			Image::Bind()
  {
	this->_Bind();
  }
}
